[php] Cookies only changing value every two page refreshes?
Posted
by Gazillion
on Stack Overflow
See other posts from Stack Overflow
or by Gazillion
Published on 2010-04-20T02:44:35Z
Indexed on
2010/04/20
2:53 UTC
Read the original article
Hit count: 310
Hello,
I'm trying to implement some pixel tracking where I will save certain values in a cookie to then forward users to another page. If users purchase a product after being forwarded to the online store by us the store adds an image tag in the page with our php script included. With the values set in the cookie we would like to track conversions.
I understand this tracking technique has some limitations (like if a user has cookies turned off or if they do not load images but that's the direction my client wanted to go in).
The problem I'm having is that the cookie's behaviour is extremely... random. I've been trying to track their values (with a var_dump so I don't have to wait for a page reload to view the cookie's value) but it seems the value for one field only gets refreshed every two page reloads.
setcookie("tracking[cn]", $cn, time()+3600*24*7,'/','mydomain.com');
setcookie("tracking[t]", $t, time()+3600*24*7,'/','mydomain.com');
setcookie("tracking[kid]", $kid, time()+3600*24*7,'/','mydomain.com');
redirectTo($redirect_url);
the values of cn, t are fine but for some reason kid is always wrong (having taken the value of the previous kid)
Any help would be extremely appreciated I've been at this all evening! :)
© Stack Overflow or respective owner